package com.kiln.juxingqs.ui.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import client.global.commlib.network.data.JsonResult
import client.global.commlib.network.data.PagingJsonResult
import client.global.commlib.network.data.Ret
import com.kiln.juxingqs.api.bean.Wdtj
import com.kiln.juxingqs.api.bean.Zcjl
import com.kiln.juxingqs.ui.viewmodel.MiddleVm


class WdtjViewModel(app: Application) : MiddleVm(app) {
    val isShowing = MutableLiveData<Boolean>(false)

    val isOneLoading = MutableLiveData<Boolean>(false)
    val pageOne = MutableLiveData<Int>(0)
    val callOne = MutableLiveData<JsonResult<Zcjl>>()
    val cancleRet = MutableLiveData<JsonResult<Ret>>()
    val queRenRet = MutableLiveData<JsonResult<Ret>>()


    var data = pagingDataAuto<Wdtj.Json>(20, hold = {
        val ret = server.day_count().body()
        var list: List<Wdtj.Json>? = ArrayList<Wdtj.Json>()
        if (it == 1)
            list = ret?.data?.json_list

        PagingJsonResult(
            list = list,
            code = ret?.code,
            message = ret?.message
        )
    })

//    fun querenOrder() {
//        hold({
//            server.day_count(
//            )
//        }, {
//            isShowing.value = true
//        }, {
//            queRenRet.value = it
//        }, complete = {
//            isShowing.value = false
//
//        })
//    }

}